#!/user/bin/env python3
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# @File : csv_data.py
# @Time : 2022-06-23 16:24
# @Author : mojin
# @Email : 397135766@qq.com
# @Software : PyCharm
#-------------------------------------------------------------------------------


#!/usr/bin/python3
# -*- coding: utf-8 -*-

# 导入CSV安装包
import csv,os,time

def create_csv(path):

    with open(path,'w',encoding='utf-8',newline="") as f:
        csv_write = csv.writer(f)
        csv_head = ['time','iphone_info', 'package', 'mem', 'cpu', 'systemCpu', 'rxBytes', 'txBytes', 'rxTcpBytes', 'txTcpBytes', 'fps', 'level','batterytem']
        csv_write.writerow(csv_head)

def write_csv(path,list_row):
    #a, b, c, d, e, f, g, h, i, j, k, l, m=list_row

    with open(path,'a+',encoding='utf-8',newline="") as f:
        csv_write = csv.writer(f)
        csv_write.writerow(list_row)

def write_csv_list(path,list_data):
    for i in list_data:

        write_csv(path, i)


# csv_path= os.getcwd() + "/test_dataCSV/"+time.strftime("%Y%m%d%H%M%S", time.localtime(time.time())) + '.csv'
# create_csv(csv_path)
#
# for i in range(20):
#     list_row=['2020-04-01 14:21:57.381', 'Xiaomi MIMAX;msm8952;3G', 'com.hualv.myliveroomplay', 154.128, 1.33, 14.27, 0.0, 0.0, 0.0, 0.0, 0, 83, 29.0]
#     print(len(list_row))
#     write_csv(csv_path, list_row)
